xend: Fix scsi_id for pvSCSI
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 31 Mar 2009 10:27:10 +0000 (11:27 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 31 Mar 2009 10:27:10 +0000 (11:27 +0100)
pvSCSI allocations fail if the version of udev in a host OS is
relatively new.  I have not been able to detect the failure because
I have used udev of the version 095.  The failure occurs by
an incompatibility problem of scsi_id command included udev.
This patch tackles the incompatibility problem.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
tools/python/xen/util/vscsi_util.py

index 3b8d0536a82325142d4a565278f8043eb1036955..a61f10455aec77df4fda79290779545caeee259c 100644 (file)
@@ -36,6 +36,11 @@ SYSFS_SCSI_DEV_TYPEID_PATH = '/type'
 SYSFS_SCSI_DEV_REVISION_PATH = '/rev'
 SYSFS_SCSI_DEV_SCSILEVEL_PATH = '/scsi_level'
 
+SCSI_ID_COMMANDS = [
+    "/lib/udev/scsi_id -gu --sg-version 3 -d /dev/%s 2>/dev/null",
+    "/sbin/scsi_id -gu -s /class/scsi_generic/%s 2>/dev/null"
+]
+
 def _vscsi_get_devname_by(name, scsi_devices):
     """A device name is gotten by the HCTL.
     (e.g., '0:0:0:0' to '/dev/sda')
@@ -79,9 +84,10 @@ def _vscsi_get_hctl_by(phyname, scsi_devices):
 
 
 def _vscsi_get_scsiid(sg):
-    scsi_id = os.popen('/sbin/scsi_id -gu -s /class/scsi_generic/' + sg).read().split()
-    if len(scsi_id):
-        return scsi_id[0]
+    for scsi_id_command in SCSI_ID_COMMANDS:
+        scsi_id = os.popen(scsi_id_command % sg).read().split()
+        if len(scsi_id):
+            return scsi_id[0]
     return None